package com.jzx.provider.cv.service;

import com.hankcs.hanlp.dictionary.CustomDictionary;
import com.jzx.provider.cv.repository.KeyWordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.jzx.provider.cv.model.KeyWork;

import java.util.List;

@Service
public class KeyWordService {
    @Autowired
    private KeyWordRepository keyWordRepository;

    public void createDir() {
        for (int i = 1; i < 1000; i++) {
            List<KeyWork> keyWords = keyWordRepository.findByPage((i - 1) * 100, 100);
            if (keyWords == null || keyWords.size() == 0) {
                return;
            }
            keyWords.forEach(keyWork -> {
                CustomDictionary.insert(keyWork.getName(), keyWork.getType() + " " + keyWork.getWeight());
            });
        }
    }
}
